package com.liuqi.openai.data.message;

import static com.liuqi.openai.data.message.ChatMessageType.TOOL_RESULT;

/**
 * 工具调用结果消息
 *
 * @author liuqi
 * @date 2025/7/19
 **/
public class ToolResultMessage extends ChatMessage {

    /**
     * 工具名称
     */
    private final String name;

    /**
     * 工具调用ID
     */
    private final String toolCallId;

    /**
     * @param name          工具名称
     * @param toolCallId    工具调用ID
     * @param result        工具调用结果
     */
    ToolResultMessage(String name, String toolCallId, String result) {
        super(result, TOOL_RESULT);
        this.name = name;
        this.toolCallId = toolCallId;
    }

    public String name() {
        return this.name;
    }

    public String toolCallId() {
        return this.toolCallId;
    }

    public static ToolResultMessage from(String name, String toolCallId, String result) {
        return new ToolResultMessage(name, toolCallId, result);
    }

    public static ToolResultMessage toolResultMessage(String name, String toolCallId, String result) {
        return from(name, toolCallId, result);
    }

    @Override
    public String toString() {
        return "ToolResultMessage{" +
                "name='" + name + '\'' +
                ", toolCallId='" + toolCallId + '\'' +
                ", result='" + text + '\'' +
                ", type=" + type +
                '}';
    }
}
